package com.liy.teaching.config;


import com.liy.teaching.service.Service;
import com.liy.teaching.service.ServiceImpl;
import com.liy.teaching.service.ServiceImpl02;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ConditionalConfig {

    @Bean()
    @ConditionalOnProperty(name = "my.service.impl", havingValue = "serviceImpl") // 条件一 满足
    public Service service(){
        return new ServiceImpl();  //  ServiceImpl
    }


    @Bean()
    @ConditionalOnProperty(name = "my.service.impl", havingValue = "serviceImpl02")// 条件二 不满足
    public Service serviceImpl(){
        return new ServiceImpl02();//  ServiceImpl02
    }

}
